/* GUI CONVERTED from resumt.p (converter v1.75) Mon Sep 25 16:54:40 2000 */
/* resumt.p - REPETITIVE ISSUE SUBSTITUTE PART INTERFACE                */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                   */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                 */
/* REVISION: 6.0      LAST MODIFIED: 06/15/90   BY: emb */
/* REVISION: 6.0      LAST MODIFIED: 02/20/92   BY: emb *F234*/
/* Revision: 7.3        Last edit: 09/27/93             By: jcd *G247* */
/* REVISION: 7.3      LAST MODIFIED: 01/27/93   BY: emb *G689*/
/* REVISION: 7.3      LAST MODIFIED: 03/17/94   BY: ais *GJ12*/
/* Oracle changes (share-locks)    09/12/94           BY: rwl *FR25*    */
/* REVISION: 7.3      LAST MODIFIED: 04/26/96   BY: rvw *G1TJ*          */
/* REVISION: 7.3    LAST MODIFIED: 08/29/96 BY: *G2D9* Julie Milligan   */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98 BY: *K1Q4* Alfred Tan       */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00 BY: *N0KP* myb              */
/* REVISION: 9.1    LAST MODIFIED: 09/05/00 BY: *N0K2* Phil DeRogatis   */

         {mfdeclre.i}

{gplabel.i} /* EXTERNAL LABEL INCLUDE */

         define shared variable pk_recno as recid.
         define shared variable ophist_recid as recid.
         define variable pts_recno as recid.
         define buffer pkdet for pk_det.
         define variable open_qty like mrp_qty.
         define variable qty_chg like pk_qty.
         define shared variable part like pk_part.
         define shared variable lotserial_qty like sr_qty no-undo.
/*       define shared variable mfguser as character.         *G247* */

/*F234*/ define variable temp_qty like pk_qty.
/*GJ12* /*G689*/ define variable cline like sr_lineid.               */
/*GJ12*/ define shared variable cline like sr_lineid.

         find pk_det where recid(pk_det) = pk_recno no-error.
         find op_hist no-lock where recid(op_hist) = ophist_recid.

/*G689*/ cline = "-" + string(pk_part,"x(18)") + pk_reference.
/*G1TJ*/ /* Changed following parameter to include width              */
/*G1TJ*  &frame-attr="overlay col 30 row 15"                          */

/*G2D9*/ /*CHANGE &frame-attr FROM overlay col 30 row 15 width 46     */
/*G2D9*/ /*                     TO overlay col 12 row 15 width 67     */
/*G2D9*/ /*   ADD &display=pts_par AFTER &display=pts_sub             */

/*F234*/ {swindowa.i
         &file=pts_det
         &framename="c"
         &frame-attr="overlay col 12 row 15 width 67"
         &record-id=pts_recno
         &search=pts_part
         &equality=pk_part
         &other-search="and (pts_par = """" or pts_par = op_part)"
         &scroll-field=pts_sub
         &create-rec=no
         &update-leave=yes
         &display1=pts_sub
         &display2=pts_par
         &display3=pts_qty_per
         &display4="pts_qty_per * lotserial_qty @ qty_chg"
         }

         if keyfunction(lastkey) = "end-error" then leave.
         find pts_det no-lock where recid(pts_det) = pts_recno no-error.
         if not available pts_det then leave.

         find pt_mstr no-lock where pt_part = pts_sub no-error.
         if not available pt_mstr then leave.

/*F234*/ qty_chg = pts_qty_per * lotserial_qty.

         if pk_qty >= 0
         then pk_qty = max(pk_qty - lotserial_qty,0).
         else pk_qty = min(pk_qty - lotserial_qty,0).

/*F234*/ open_qty = lotserial_qty.

/*fr25*/ for each sr_wkfl exclusive-lock where sr_userid = mfguser
/*G689*  and sr_lineid = pk_part: */
/*G689*/ and sr_lineid = cline:

/*F234*/    if sr_qty < 0 and open_qty < 0
/*F234*/    then temp_qty = max(sr_qty,open_qty).
/*F234*/    else temp_qty = min(sr_qty,open_qty).

/*F234*/    open_qty = open_qty - temp_qty.
/*F234*/    sr_qty = sr_qty - temp_qty.
/*F234*/    if sr_qty = 0 then
            delete sr_wkfl.
         end.

         part = pts_sub_part.
         lotserial_qty = qty_chg.
/*GJ12*/ cline = "-" + string(part,"x(18)") + pk_reference.
